<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
	<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
	<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ include file="../../common/base.jsp"%>
<%
	response.setCharacterEncoding("utf-8");
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Insert title here</title>
<link href="${path }/dist/css/bootstrap.css" rel="stylesheet">
<link href="${path }/dist/css/bootstrap-overrides.css" rel="stylesheet">

<!-- Button -->
<link href="${path }/dist/css/compiled/elements.css" rel="stylesheet">
<!-- libraries -->
<link rel="stylesheet" type="text/css"  href="${path }/dist/css/font-awesome.css">
<!-- this -->
<link rel="stylesheet" type="text/css" href="${path }/dist/css/app.css">
<link href='${path }/dist/css/zTreeStyle/zTreeStyle.css' rel='stylesheet' />
<link href="${path }/dist/css/bootstrap-datetimepicker.min.css" rel="stylesheet"><%--时间日期工具 --%>

<link rel="stylesheet" type="text/css" href="${path }/back/ifrom.css">
<script src="${path }/dist/js/jquery.min.js"></script>
<script src='${path }/dist/js/bootstrap.min.js'></script>
<script src="${path }/dist/js/ajaxfileupload.js"></script><%--文件ajax 插件 --%>
<script src="${path }/dist/js/theme.js"></script>
<script src='${path }/dist/js/jquery.ztree.core-3.5.js'></script>
<script src='${path }/dist/js/jquery.ztree.excheck-3.5.js'></script>
<script src='${path }/dist/js/jquery.ztree.exedit-3.5.js'></script>
<script src="${path }/dist/js/bootstrap-datetimepicker.min.js"></script>
<script src="${path }/dist/js/bootstrap-datetimepicker.zh-CN.js"></script>

<style>
table tr>td.title{
		width: 85px;
		padding-right: 0px;
	}
.left_tree{
	height: 430px;
	overflow: auto;
	border: 1px solid #ccc;
	 border-radius: 5px;
}
#pad-wrapper h3{
	font-family: "黑体";
}
#from_table input,
#from_table input:hover,
#from_table input:focus{
	border-left: none !important;
	border-right: none !important;
	border-top: none !important;
	background-color: transparent !important;
	color: #000 !important;
	box-shadow:none !important;
}
#from_table input[readonly]{
	cursor: pointer;
}
#add_edit_table.table tr>td{
	padding:  2px 5px;
	max-width: 100px;
	height: 20px;
	
}
#add_edit_table.table tr>td select{
	width: 100%;
}
.menuContent {padding-top: 10px;border: 1px solid #617775;background: #f0f6e4;width:160px;height:260px;overflow-y:scroll;overflow-x:auto;}
.btn-group-vertical{
	width: 100%;
}
i{
	margin-right: 5px;
}
#node_tbody tr>td>input{
	border: none;
	background-color: #fff;
	color: #000;
	display: inline;
}
</style>
</head>
<bady>
<div class="container-fluid" style="padding: 0 30px 0 50px;">
	<div class="row head">
	<div class="col-md-12">
			<h3>编辑资产<em><small>编辑资产时切勿刷新页面，以免造成数据丢失</small></em></h3>
			</div>
	</div>
	<hr>
	<div class="row">
		<div class="panel panel-default">
		<div class="panel-body" style="padding: 0px;">
			
			<div class="table-responsive">
			<form action="#" method="post" id="row_form">
				
				<table class="table table-hover" id='add_edit_table'>
					<tbody>
						<tr><td class="title"  title="使用流水编号" >
   								<span style="color: red;">*编号：</span></td>
							<td><%
								String is_auto_number=(String)request.getAttribute("is_auto_number");
								if("0".equals(is_auto_number)){
							%>
							<input type="text" class="form-control input-sm" name="a_number" data-vail/>
							<%}else{ %>
								<input type="text" class="form-control input-sm" name="a_number" data-vail readonly="readonly" value="auto"/>
							<%} %>
							</td>
							<td class="title"><span style="color: red;">资产类别：</span></td>
							<td><input type="text" class="form-control input-sm" name="a_class_name" data-vail readonly="readonly"  data-close/></td>
							<td class="title"><span style="color: red;">资产名称：</span></td>
							<td><input type="text" class="form-control input-sm" name="a_name" data-vail  data-close/></td>
							<td class="title">规格型号：</td>
							<td><input type="text" class="form-control input-sm" name="a_specification" data-close/></td>
							
						</tr>
						<tr><!-- <td class="title">使用部门：</td>
							<td><input type="text" class="form-control input-sm" name="dept_name" readonly="readonly"/><input type="hidden" name='dept_id'/></td>
							
							<td class="title">保管人员：</td>
							<td><input type="text" class="form-control input-sm" name="a_custody_staff" list="a_custody_staff_list"/>
									<datalist id="a_custody_staff_list">
									</datalist>
							</td> -->
							<td class="title">计量单位：</td>
							<td>
								<select name="a_measure">
									<c:forEach var="wal" items="${assetsMeasureList }">
				    				<option value="${wal.measure_name }">${wal.measure_name }</option>
									</c:forEach>
								</select>
							</td>
							<td class="title">存放地点：</td>
							<td>
								<select name='a_store'>
									<c:forEach var="wal" items="${assetsStoreList }">
				    				<option value="${wal.measure_name }">${wal.measure_name }</option>
									</c:forEach>
								</select></td>
							<td class="title">资产状态：</td>
							<td>
								<select name='a_status'>
									<%-- <c:forEach var="wal" items="${assetsStatusList }">
				    				<option value="${wal.measure_name }">${wal.measure_name }</option>
									</c:forEach> --%>
									<option value="闲置">闲置</option>
								</select>
							</td>
							<td class="title">资产来源：</td>
							<td>
								<select name="a_source">
									<c:forEach var="wal" items="${assetsSourceList }">
				    				<option value="${wal.measure_name }">${wal.measure_name }</option>
									</c:forEach>
								</select>
							</td>
						</tr>
						<tr><td class="title">购置日期：</td>
							<td><input type="text" class="form-control input-sm form_datetime" name="a_buy_date" readonly="readonly"/></td>
							<td class="title">登记日期：</td>
							<td><input type="text" class="form-control input-sm form_datetime" name="a_register_data" readonly="readonly"  data-close value="<fmt:formatDate value="${date}" pattern="yyyy-MM-dd"/>"/></td>
							<td class="title">供应商：</td>
							<td colspan="3"><input type="text" class="form-control input-sm" name='suppliers' placeholder="名称,地址,联系人,电话,传真（使用英文符‘,’连接）" data-close/><input type="hidden" name='suppliers_id' data-close/></td>
							<td colspan="2" rowspan="5" style="border: 1px solid #000 !important; overflow: auto;">
								<div style="height: 180px;width: 260px;">
									<img alt="..." src="http://usr.im/200x150?text=图片信息" id="show_img">
								</div>
							</td>
						</tr>
						<tr><td class="title">备注：</td>
							<td colspan="3"><textarea rows="" cols="" wrap="virtual" class="form-control" name='a_remark' data-close></textarea></td>
							<td class="title">图片：</td>
							<td colspan="3"><input type="file" name="uploadimage" onchange="uploadImg(this)" id="img_input" data-close/><input type="hidden" name='a_img_src' data-close/>
							</td>
							</tr>
							<!-- <tr ><td colspan="10" style="height: auto;padding: 0;"><hr></td></tr> -->
						<tr>
							<td class="title">资产数量：</td>
							<td>
							<%
								
								if("0".equals(is_auto_number)){
							%>
								<input type="text" class="form-control input-sm" name="number" value="1" data-default='1' readonly="readonly"/></td>
							<%}else{ %>
								<input type="text" class="form-control input-sm" name="number" value="1" data-default='1' /></td>
							<%} %>
								
							<td class="title"><span style="color: red;">资产单价：</span></td>
							<td><input type="text" class="form-control input-sm" name="a_unit_price" placeholder="0.00" data-close data-vail/></td>
							<td class="title"><span style="color: red;">使用年限：</span></td>
							<td class="input-group"><input type="text" class="form-control input-sm" name="a_years" placeholder="0" data-default='3' data-vail/><div class="input-group-addon">年</div></td>

							
							<td class="title"><span style="color: red;">净残值率：</span></td>
							<td class="input-group"><input type="text" class="form-control input-sm" name="a_jc_rate" placeholder="0.00" data-close data-vail/><div class="input-group-addon">%</div></td>
  						</tr>
						<tr>
							<td class="title">折旧方式：</td><td>
								<select name="a_d_m">
									<option value="无">无</option>
									<option value="平均年限法">平均年限法</option>
								</select>
							</td>
							<td class="title">财务编码：</td>
							<td><input type="text" class="form-control input-sm" name="a_f_number" data-close/></td>
							<td class="title">机器序号：</td>
							<td><input type="text" class="form-control input-sm" name="a_machine_no"  data-close/></td>
							<!-- <td class="title">月提折旧：</td>
							<td><input type="text" class="form-control input-sm" name="a_ytd" placeholder="0.00" readonly="readonly" value="0.00" data-default='0.00'/></td>
							<td class="title">累计折旧：</td>
							<td><input type="text" class="form-control input-sm" name="a_count_d" placeholder="0.00" value="0.00" readonly="readonly" data-default='0.00'/></td>
							<td class="title">净值：</td>
							<td><input type="text" class="form-control input-sm" name="a_j_value" placeholder="0.00" value="0.00" readonly="readonly" data-default='0.00'/></td> -->
						</tr>
					</tbody>
					<tfoot>
						<tr>
							<td colspan="10" style="text-align:center;">
								<button type="button" class="btn btn-primary" id="add_new_one"><i class="icon-ok"></i>增加</button>
								<button type="button" class="btn btn-primary" onclick="clear_table()"><i class="icon-undo"></i>清空</button>
							</td>
						</tr>
					</tfoot>
				</table>
				</form>
			</div>

			<div class="row" style="margin-bottom: 10px;margin: 0px;">
				<form action="${path }/back/assetsMS!saveAll" id="edit_edit_form" method="post" target="curWindow">
				<div class="col-md-10" style="overflow-x: auto;">
					<table class="table-hover" id='from_table'>
						<tr>
							<td>单据号</td>
							<td><input type="text" name='receiptBean.no' class="form-control input-sm" value="${receipt_no }"/></td>
							<td>盘点人</td>
							<td><input type="text" name="receiptBean.user_id" class="form-control input-sm" value="${user.user_account }"  readonly="readonly"/></td>
						</tr>
						<tr>
							<td>单据摘要</td>
							<td colspan="3"><input type="text" class="form-control input-sm" name="receiptBean.receipt_remark" value="[福建XXX公司有限公司 入库单] "/></td>
							<td>入库日期:</td>
							<td><input type="text" class="form-control input-sm" name="receiptBean.receipt_data" 
								readonly="readonly" value="<fmt:formatDate value="${date}" pattern="yyyy-MM-dd"/>" readonly="readonly"/></td>
						</tr>
					</table>
					<div style="width: 2600px; height: 280px;">
						<table class="table table-striped" id='add_edit_List'>
							<thead>
									<tr id="table_title" class="table_title">
										<th class="sortable" ><span><input type="checkbox" /></span></th>
										<th class="sortable" ><span>资产编号</span ></th>
										<th class="sortable" ><span class="line"></span><span >类别名称</span></th>
										<th class="sortable" ><span class="line"></span><span >资产名称</span></th>
										<th class="sortable" ><span class="line"></span><span >规格型号</span></th>
										<th class="sortable" ><span class="line"></span><span >计量单位</span></th>
										 <!-- <th class="sortable" ><span class="line"></span><span >使用部门</span></th>
										<th class="sortable" ><span class="line"></span><span >部门Id</span></th> 
										
										 <th class="sortable" ><span class="line"></span><span >保管人员</span></th>
										  -->
										  <th class="sortable" ><span class="line"></span><span >存放地点</span></th>
										<th class="sortable" ><span class="line"></span><span >资产状态</span></th>
										<th class="sortable" ><span class="line"></span><span >资产来源</span></th>
										<th class="sortable" ><span class="line"></span><span >购置日期</span></th>
										<th class="sortable" ><span class="line"></span><span >登记日期</span></th>
										<th class="sortable" ><span class="line"></span><span >供应商</span></th>
										<th class="sortable" ><span class="line"></span><span >供应商ID</span></th>
										<th class="sortable" ><span class="line"></span><span >备注</span></th>
										<th class="sortable" ><span class="line"></span><span>图片</span></th>
										<th class="sortable" ><span class="line"></span><span >资产数量</span></th>
										<th class="sortable" ><span class="line"></span><span >资产单价</span></th>
										<th class="sortable" ><span class="line"></span><span >使用年限</span></th>
										<th class="sortable" ><span class="line"></span><span >净残值率</span></th>
										<th class="sortable" ><span class="line"></span><span >折旧方式</span></th>
								<!-- 		<th class="sortable" ><span class="line"></span><span >月提折旧</span></th>
										<th class="sortable" ><span class="line"></span><span >累计折旧</span></th>
										<th class="sortable" ><span class="line"></span><span >净值</span></th> -->
										<th class="sortable" ><span class="line"></span><span >财务编码</span></th>
										<th class="sortable" ><span class="line"></span><span >机器序号</span></th>
									</tr>
								</thead>
								<tbody id="node_tbody">
									
								</tbody>
						</table>
					</div>
				</div>
				<div class="col-md-2" style="padding-left: 0px;">
					<div class="btn-group-vertical" >
						<button type="button" class="btn btn-default" id="save_all"><i class="icon-save"></i>全部保存</button>
						<button type="button" class="btn btn-default" id="copy_row"><i class="icon-copy"></i>复制</button>
		  				<button type="button" class="btn btn-default" id="ref_edit"><i class="icon-edit"></i>重新编辑</button>
		  				<button type="button" class="btn btn-default" id="remove_row"><i class="icon-trash"></i>删除</button>
		  				<button type="button" class="btn btn-default" id="clear_list"><i class="icon-repeat"></i>清空</button>
					</div>
				</div>
			</form>
			</div>
		</div>
	</div>
	</div>
</div>
<div id="a_class_nameMenu" class="menuContent" style="display:none; position: absolute;">
	<ul id="assetstree" class="ztree menutree"></ul>
</div>
<!-- <div id="dept_nameMenu" class="menuContent" style="display:none; position: absolute;">
	<ul id="dept_nametree" class="ztree menutree" style=""></ul>
</div> -->
<div id="suppliersMenu" class="menuContent" style="display:none; position: absolute;width: 330px;">
	<div style="width: 600px;" >
	<table id="supplierstable" class="table table-hover" >
		<thead>
			<tr>
				<th>名称</th>
				<th>地址</th>
				<th>联系人</th>
				<th>电话</th>
				<th>传真</th>
			</tr>
		</thead>
		<tbody>
			<c:forEach var="l" items="${assetsSuppliersList}">
				<tr data-id='${l.id }'>
					<td>${l.suppliers_name }</td>
					<td>${l.suppliers_address }</td>
					<td>${l.suppliers_contacts }</td>
					<td>${l.suppliers_phone }</td>
					<td>${l.suppliers_fax }</td>
				</tr>
				</c:forEach>
		</tbody>
	</table>
	</div>
</div>
	<script type="text/javascript">
		window.name = "curWindow";
		var edit_row_index=null;
		var setting = {
				view: {
					selectedMulti: false,//多选
					showLine: true,
					nameIsHTML: true
				}, callback : {
					beforeClick : assetsclasstree,
				},data:{
					simpleData:{
						enable: true,
					}
				}
			};
/* 		var setting_dept = {
				view: {
					selectedMulti: false,//多选
					showLine: true,
					nameIsHTML: true
				}, callback : {
					beforeClick : dept_nametree,
				},data:{
					simpleData:{
						enable: true,
					}
				}
			}; */
		//清空table 输入的数据
		function clear_table(){
			$("#row_form input[data-close]").each(function(){
				$(this).val("");
			});
			$("input[data-default]").each(function(){
				if($(this).data('default')!=null&&$(this).data('default')!="")
				$(this).val($(this).data('default'));
			});
		}
		//上传图片
		function uploadImg(obj){
			$.ajaxFileUpload({
				url:"${path}/uploadFileAction!upimg",
				secureuri:false,
				fileElementId:"img_input",
				dataType: 'json',
				data:{name:'logan', id:'id'},
				success: function (data, status) {
					if(data.message.info){
						$("#show_img").attr("src",data.href);
						//alert(data.img_name);
						$("input[type='hidden'][name='a_img_src']").val(data.img_name);
						//alert($("input[type='hidden'][name='a_img_src']").val());
					}else{
						alert(data.text+"请重新上传");
					}
				},
				error: function (data, status, e) {
				}
			})
		}
		/* //选择部门   部门树子节点被点击
		function dept_nametree(treeId, treeNode){
			if(treeNode.isParent){
				return true;
			}else{
				$("input[name='dept_name']").val(treeNode.name);
				$("input[type='hidden'][name='dept_id']").val(treeNode.id);
				$("input[name='a_store']").val(treeNode.name);
				
				var saveURL = "${path}/back/staff!getstaffBydeptToname?date="+new Date()+"";
				jQuery.post(saveURL,[{name:"id",value:treeNode.id}],function(jsonData){
					var target =$("#a_custody_staff_list");
					target.empty();//清空
					if(jsonData!=null){
						for(var j=0;j<14;j++){//jsonData.length
							$("<option label='"+jsonData[j].STAFF_NAME+"' value='"+jsonData[j].STAFF_NAME+"' />").appendTo(target);
						}
					}
				},"json");
			}
			return true;
	
		} */
		//资产分类树点击事件
		function assetsclasstree(treeId, treeNode){
		//	if(treeNode.isParent){
		//		return true;
		//	}else{
				$("input[name='a_class_name']").val(treeNode.name);
		//	}
			return true;
		}
		
		
	$(document).ready(function() {
		//window.parent.onbeforeunload="return '当前页面还有未保存的数据，确定不保存就离开了吗？';"
		//$("#row_form [name='a_d_m']").val("平均年限法");
		//资产树
		var saveURL = "${path}/back/tree!assetsclasstree?date="+new Date()+"";
		jQuery.post(saveURL,null,function(jsonData){
			$.fn.zTree.init($("#assetstree"),setting,jsonData);
		},"json");
		/* //获取部门树
		saveURL = "${path}/back/tree!deptTree?date="+new Date()+"";
		jQuery.post(saveURL,null,function(jsonData){
			$.fn.zTree.init($("#dept_nametree"),setting_dept,jsonData);
		},"json"); */

		//展开资产分类树
		$("input[name='a_class_name']").bind("focus",{id:"#a_class_nameMenu"},function(e){
			var cityObj = $(this);
			var cityOffset = cityObj.offset();
			$(e.data.id+"").css({left:cityOffset.left + "px", top:cityOffset.top + cityObj.outerHeight() + "px"}).slideDown("fast");
			$("body").bind("mousedown",{id:e.data.id}, onBodyDown);
		});
		/* //展开部门分类树
		$("input[name='dept_name']").bind("focus",{id:"#dept_nameMenu"},function(e){
			var cityObj = $(this);
			var cityOffset = cityObj.offset();
			$(e.data.id+"").css({left:cityOffset.left + "px", top:cityOffset.top + cityObj.outerHeight() + "px"}).slideDown("fast");
			$("body").bind("mousedown",{id:e.data.id}, onBodyDown);
		}); */
		//展开供应商table
		$("input[type='text'][name='suppliers']").bind("focus",{id:"#suppliersMenu"},function(e){
			var cityObj = $(this);
			var cityOffset = cityObj.offset();
			$(e.data.id+"").css({left:cityOffset.left + "px", top:cityOffset.top + cityObj.outerHeight() + "px"}).slideDown("fast");
			$("body").bind("mousedown",{id:e.data.id}, onBodyDown);
		});
		//供应商 行被点击事填充
		$("#supplierstable tbody>tr").click(function(){
			var text=new Array();
			$(this).find("td").each(function(index,i){
				var $td=$(i);
				text.push($td.html());
			});
			$("input[name='suppliers']").val(text.join(','));
			$("input[name='suppliers_id']").val($(this).data("id"));
			$(this).closest(".menuContent").fadeOut("fast");
		});
		//新增一行
		$("#add_new_one").click(add_event);
		//保存全部
		$("#save_all").click(function(){
			//alert(formDom.serializeArray().length);
			if($("#node_tbody").find("tr").length>0){//至少有一行数据才可以添加
				var formDom=$(this).closest("form");
				
				formDom.submit();
				window.returnValue="添加成功";
				window.close();
			}else{
				alert("至少一行数据");
			}
		});
		//重新编辑
		$("#ref_edit").click(function(){
			var checkbox_obj=$(".table tr>td input:checkbox:checked");
			if(checkbox_obj.length==1){
				var tr_obj=checkbox_obj.parent().parent();
				edit_row_index= tr_obj.index();
				fillingtr(tr_obj);
				tr_obj.remove();
			}else{
				alert("重新编辑不能选择多行");
			}
		});
		//复制行
		$("#copy_row").click(function(){
			if(confirm("确认复制吗？")){
				var checkbox_obj=$(".table tr>td input:checkbox:checked");
				var target=$("#node_tbody");
				checkbox_obj.each(function(){
					//.clone().appendTo(target);
					var tr_obj=$(this).parent().parent();
					fillingtr(tr_obj);
					add_event();
					clear_table();
				});
			}else
				return false;
		});
		//删除行
		$("#remove_row").click(function(){
			if(confirm("确认删除吗？这个操作不可撤销")){
				var checkbox_obj=$(".table tr>td input:checkbox:checked");
				var target=$("#node_tbody");
				checkbox_obj.each(function(){
					$(this).parent().parent().remove();
				});
			}else
				return false;
		});
		//清空
		$("#clear_list").click(function(){
			if(confirm("确认清空吗？这个操作不可撤销")){
				var target=$("#node_tbody").empty();
			}else
				return false;
		});
	});
	function fillingtr(obj,index){
		$("input[type=text]",obj).each(function(){
			var name=$(this).attr('name');
			var input_name=name.replace(/.*(\/|\\)/, "");
			var input_nameExt=(/[.]/.exec(input_name)) ? /[^.]+$/.exec(input_name.toLowerCase()) : '';
			$("#row_form [name='"+input_nameExt+"']").val($(this).val());
			
		});
		$("#show_img").attr('src',obj.data('img-src'));
	}
	function add_event(){
		var formDom=$("#row_form");
		if(fromisnotnull(formDom)){
			addrowRec(formDom);
		}
		
	}
	//增加一行
	function addrowRec(fromDom){
		var rowRec=fromDom.serializeArray();
		var target=$("#node_tbody");
		var target_count;
		
		if(edit_row_index==null)
			target_count=$("#node_tbody").find("tr").length;
		else{
			target_count=edit_row_index;
			alert(edit_row_index);
		}
		var tr_obj=$("<tr data-img-src='"+fromDom.find('#show_img').attr('src')+"'></tr>").appendTo(target);
		//var target_count=tr_obj.index();
		var td_obj=$("<td></td>").appendTo(tr_obj);
		$("<input type='checkbox' name='select_row'>").appendTo(td_obj);
		$.each(rowRec,function(index,v){
			//alert(v.name+":"+v.value);
			td_obj=$("<td></td>").appendTo(tr_obj);
			$("<input type='text' value='"+v.value+"' class='form-control input-sm' readonly name='assetslist["+target_count+"]."+v.name+"'/>").appendTo(td_obj);
		}) 
		edit_row_index=null;
	}
	//时间日期
	$(".form_datetime").datetimepicker({format: 'yyyy-mm-dd',language:  'zh-CN',weekStart: 1,
        todayBtn:  1,
		autoclose: 1,
		todayHighlight: 1,
		startView: 2,
		forceParse: 0,
        showMeridian: 1,
        minView: 2,
        pickerPosition:"bottom-left"});
	//判断表单导游data-vail 属性是否为空
	function fromisnotnull(fromdom){
		var  pass =true;
		$("input[type='text'][data-vail]",fromdom).each(function(){
			if($(this).val()==null||$(this).val()==""){
				alert("红色为必填项");
				pass =false;
				return false;
			}
		});
		return pass;
	}
	function onBodyDown(evetnt){
		if(!($(evetnt.target).closest(evetnt.data.id).length>0)){
			hidetree(evetnt.data.id);
		}
	}
	//解除 body绑定
	function hidetree(id){
		$(id+"").fadeOut("fast");
		$("body").unbind("mousedown",onBodyDown);
	}
	</script>
		<c:if test="${tip!=null }">
<script type="text/javascript">
 alert('${tip}');
</script>
</c:if>
</bady>
</html>
<%--	alert(1);

		    var c = $(window.parent.document.body) 
		    //麻烦的方法：
		    //var c = $($(window).eq(0)[0].parent.document).find('body'); //，忘了可以用前面的方法了
		    c.bind('beforeunload', function(e) {    
		        // Mozilla takes the
		        alert(1);
		    }); --%>